package com.su.lesson05;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class JButtonDemo01 extends JFrame {
    public JButtonDemo01() {
        //将一个图片变成一个图标
        Container container = getContentPane();
        URL resource = JButtonDemo01.class.getResource("头像.jpg");
        Icon icon = new ImageIcon(resource);

        //把这个图标放在按键上
        JButton button = new JButton(icon);
        container.add(button);

        setVisible(true);
        setSize(300, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[] args){
        new JButtonDemo01();
    }
}
